package org.zhangjq.myproject.transactiontest;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * 功能描述
 *
 * @author: zhangjq
 * @date: 2024年01月20日 11:52
 */

@Service
public class ServiceB {

    @Resource
    private UserMapper userMapper;

    @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRES_NEW)
//    @Transactional(rollbackFor = Exception.class)
    public void methodB(User user){

        userMapper.insert(user);

        try {
            int i = 1/0;
        }catch (Exception e){
            e.printStackTrace();
        }

    }
}